package com.hxci.hospital.controller;

import com.hxci.hospital.pojo.Patient;
import com.hxci.hospital.service.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/hospital/patient")
public class PatientController {

    @Autowired
    private PatientService patientService;

    // 患者挂号页面
    @RequestMapping("/appointment")
    public String appointment() {
        return "hospital/patient/appointment";
    }

    // 保存患者挂号信息
    @ResponseBody
    @RequestMapping("/save")
    public Integer save(Patient patient) {
        return patientService.add(patient);
    }

    // 查询所有患者
    @ResponseBody
    @RequestMapping("/queryAll")
    public List<Patient> queryAll() {
        return patientService.queryAll();
    }

    // 根据ID查询患者
    @ResponseBody
    @RequestMapping("/queryById")
    public Patient queryById(Integer id) {
        return patientService.queryById(id);
    }
}
